<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>6 和 9 组成的最大数字</title>
</head>
<body>
  <script>
    function fn(num) {
      let list = String(num).split('')
      for (let i = 0; i < list.length; i++) {
        if (list[i] === '6') {
          list[i] = '9'
          return +(list.join(''))
        }
      }
      return num
    }
    console.log(fn(9669))
  </script>
</body>
</html>